package com.iweb.tmall.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
/*
        ApiAuthInterceptor apiAuthInterceptor = apiAuthInterceptor();
*/
        registry.addInterceptor(apiAuthInterceptor())
                .addPathPatterns("/api/**")
                .excludePathPatterns("/api/admin/login")
                .excludePathPatterns("/api/admin/login2");
/*
        PageAuthInterceptor pageAuthInterceptor = new PageAuthInterceptor();
*/
        registry.addInterceptor(pageAuthInterceptor())
                .addPathPatterns("/pages/**")
                .addPathPatterns("/index.html")
                .excludePathPatterns();
    }
    @Bean
    public ApiAuthInterceptor apiAuthInterceptor(){
        return new ApiAuthInterceptor();
    }
    @Bean
    public PageAuthInterceptor pageAuthInterceptor(){
        return new PageAuthInterceptor();
    }
}
